/**
 * Copyright 2015-2016 com.eyaomall
 * All rights reserved.
 *
 * @project
 * @author pro
 * @version 1.0
 * @date 2016-03-07
 */
package com.eyaomall.wxmall.dao;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.eyaomall.wxmall.model.po.Order;
import com.eyaomall.wxmall.model.vo.OrderVO;
import com.lycheeframework.core.annotation.NameSpace;
import com.lycheeframework.core.cmp.kit.IHTTPObject;
import com.lycheeframework.core.cmp.kit.Pages;
import com.lycheeframework.core.support.DaoSupport;
@Repository
@NameSpace("order")
public class OrderDao extends DaoSupport<Order> {

	/**
	 * 新增订单
	 * @param order
	 * @return
	 */
	public Integer create(Order order){
		super.insert(order);
		
		return order.getId();
	}
	
	/**
	 * 修改订单
	 * @param order
	 * @return
	 */
	public boolean update(Order order){
		
		return super.update(order) > 0 ? true : false;
	}
	
	/**
	 * 分页查询我的订单信息
	 * @param orderVO
	 * @param httpObject
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public Pages<List<OrderVO>> page(OrderVO orderVO,IHTTPObject httpObject){
	
		return (Pages<List<OrderVO>>) super.page(orderVO, httpObject);
	}
	
	/**
	 * 查询单条我的订单信息
	 * @param orderVO
	 * @return
	 */
	public OrderVO query(OrderVO orderVO){
		
		return (OrderVO) super.query(orderVO);
	}
	
	/**
	 * 根据会员ID统计我的订单
	 * @param memberId
	 * @return
	 */
	public OrderVO calc(Integer memberId){
		OrderVO orderVO = new OrderVO();
		orderVO.setMemberId(memberId);
		
		return (OrderVO) super.query("calcOrder", orderVO);
	}
}